package com.leo.ktvplayer.base;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.leo.ktvplayer.bluetooth.LeProxy;
import com.leo.ktvplayer.domain.BaseReq;
import com.leo.ktvplayer.network.http.HttpManager;
import com.leo.ktvplayer.network.http.OnHttpCall;
import com.leo.ktvplayer.ui.setting.ActSetting;

/**
 *
 */
public class ActBase extends AppCompatActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }

    protected  void init(){

    }

    protected synchronized void sendHttp(BaseReq req,String tag){
       try {
            HttpManager httpManager = new HttpManager();
            httpManager.setHttpCall(((json, title) -> {
                httpCall(json,tag);
            }));
            httpManager.sendHttp(req,tag);

        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected  void httpCall(String json ,String tag) {

    }

    protected void goSetting(){
        Intent intent = new Intent(this, ActSetting.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }

    protected void openBle(){
        BluetoothManager manager =(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        BluetoothAdapter adapter = manager.getAdapter();
        adapter.enable();
    }

}
